package cz.boxdesign.library.web.validation;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import cz.boxdesign.library.web.view.AuthorView;

public class AutorValidator implements Validator {

  @Override
  public boolean supports(Class<?> clazz) {
    return clazz == AuthorView.class;
  }

  @Override
  public void validate(Object target, Errors errors) {
    AuthorView a = (AuthorView) target;

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "jmeno", "autor.missing.name");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "prijmeni", "autor.missing.surname");

  }

}
